package com.hjtm.easypigfarm.fragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import com.hjtm.easypigfarm.R;
import com.hjtm.easypigfarm.utility.Constants;


// Manage ment reminder
public class FragmentReminder extends Fragment {
    
    /*private final String TITLE_TAG = "title";
    private final String VALUE_TAG = "value";
    */
    GridView mGridView;
    Context mContext;
    
    private List<HashMap<String, Object>> mReminder = new ArrayList<HashMap<String, Object>>();

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initData();
	}
	
	private void initData() {
	    mReminder.clear();
        HashMap<String, Object> map = new HashMap<String, Object>();

        map.put(Constants.TITLE_TAG, "Test1");
        map.put(Constants.VALUE_TAG, "Pig farm1 needs to be cleaned today");
        mReminder.add(map);

        HashMap<String, Object> map2 = new HashMap<String, Object>();

        map2.put(Constants.TITLE_TAG, "Test2");
        map2.put(Constants.VALUE_TAG, 102.1);
        mReminder.add(map2);

	}

	@Override
	public View onCreateView(LayoutInflater inflater,
			ViewGroup container, Bundle savedInstanceState) {
	    View v = inflater.inflate(R.layout.find, null);
	    mContext = getActivity();
	    mGridView = (GridView)v.findViewById(R.id.gridV1);
	    String[] from = {Constants.TITLE_TAG, Constants.VALUE_TAG};
        int[] to = { R.id.item, R.id.value };
        SimpleAdapter adapter = new SimpleAdapter(mContext, mReminder, R.layout.list_item_value, from, to);
        mGridView.setAdapter(adapter);
		return v;
	}

}
